#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import yijiao
import ConfigParser,os,sys,subprocess
import ui_gamux_box,ui_window2
class WINDOW2(QDialog,ui_window2.Ui_Dialog):
    def __init__(self,i,parent=None):
        super(WINDOW2,self).__init__(parent)
        self.setupUi(self)
        self.dl_frame = [self.window2_frame_0,self.window2_frame_1,self.window2_frame_2,self.window2_frame_3,self.window2_frame_4,self.window2_frame_5,self.window2_frame_6,self.window2_frame_7,self.window2_frame_8,self.window2_frame_9]
        self.dl_name = [self.window2_label_name_0,self.window2_label_name_1,self.window2_label_name_2,self.window2_label_name_3,self.window2_label_name_4,self.window2_label_name_5,self.window2_label_name_6,self.window2_label_name_7,self.window2_label_name_8,self.window2_label_name_9]
        self.dl_progressbar = [self.window2_bar_0,self.window2_bar_1,self.window2_bar_2,self.window2_bar_3,self.window2_bar_4,self.window2_bar_5,self.window2_bar_6,self.window2_bar_7,self.window2_bar_8,self.window2_bar_9]
        self.dl_button_stat = [self.window2_stat_0,self.window2_stat_1,self.window2_stat_2,self.window2_stat_3,self.window2_stat_4,self.window2_stat_5,self.window2_stat_6,self.window2_stat_7,self.window2_stat_8,self.window2_stat_9]
        self.dl_button_action = [self.window2_button_action_0,self.window2_button_action_1,self.window2_button_action_2,self.window2_button_action_3,self.window2_button_action_4,self.window2_button_action_5,self.window2_button_action_6,self.window2_button_action_6,self.window2_button_action_7,self.window2_button_action_9]
        self.dl_logo = [self.window2_logo_0,self.window2_logo_1,self.window2_logo_2,self.window2_logo_3,self.window2_logo_4,self.window2_logo_5,self.window2_logo_6,self.window2_logo_7,self.window2_logo_8,self.window2_logo_9]
        for i in range(0,10):
            self.dl_button_action[i].setProperty('i',i)
            self.connect(self.dl_button_action[i],SIGNAL("clicked()"),self.kill_frame)
        for i in range(0,10):
            self.dl_button_stat[i].setProperty('i',i)
            self.connect(self.dl_button_stat[i],SIGNAL("clicked()"),self.stop_download)
        self.show_download_window()
    def stop_download(self):
        i = self.sender().property('i').toInt()[0]
        print 'ppp'
        self.show_download_window()
        file_path = self.down_items[i][7][1]
        if self.down_items[i][0][1] == 'ok':
            print 'begin to install game'
        elif self.down_items[i][0][1] == 'ing':
            if PP_START[i].poll() != 0:
                PP_START[i].kill()
                self.down_ini.set(self.down_sec_list[i],'stat','stop')
                file_size = os.path.getsize(file_path)
                self.down_ini.set(self.down_sec_list[i],'now_byte',str(file_size))
                self.down_ini.write(open(self.downloadlist,"w"))
                self.show_download_window()
                BEGINTIMER[i].stop()
        elif self.down_items[i][0][1] == 'stop':
            self.show_download_window()
            file_path = self.down_items[i][7][1]
            download_addr = self.down_items[i][2][1]
            cmd = ['wget','-c','-O',file_path,download_addr]
            PP_START[i] = subprocess.Popen(cmd)
            self.down_ini.set(self.down_sec_list[i],'stat','ing')
            self.down_ini.write(open(self.downloadlist,"w"))
            self.show_download_window()
            BEGINTIMER[i]=QTimer(self)
            BEGINTIMER[i].setProperty('obj',self)
            BEGINTIMER[i].setProperty('i',i)
            BEGINTIMER[i].setProperty('file_path',file_path)
            self.connect(BEGINTIMER[i],SIGNAL("timeout()"),box.flush )
            BEGINTIMER[i].start(500)
    @pyqtSignature("")
    def on_window2_button_close_clicked(self):
        self.hide()
    def kill_frame(self):
        i = self.sender().property('i').toInt()[0]
        self.show_download_window()
        if self.down_items[i][0][1] != 'ok':
            os.system('rm %s'%self.down_items[i][7][1])
        self.down_ini.set(self.down_sec_list[i],'stat','kill')
        self.down_ini.write(open(self.downloadlist,"w"))
        self.dl_frame[i].hide()
        self.show_download_window()
    def show_download_window(self):
        self.downloadlist = DOWNLIST
        self.down_ini = ConfigParser.ConfigParser()
        self.down_ini.read(self.downloadlist)
        self.down_sec_list = self.down_ini.sections()
        self.down_items = []
        m = 0
        n = 0
        for i in range(0,10):
            self.down_items.append(self.down_ini.items('%s'%self.down_sec_list[i]))
            if self.down_items[i][0][1] == 'kill':
                self.dl_frame[i].hide()
                m = m + 1
            else:
                y = n * 64
                self.dl_frame[i].show()
                self.dl_name[i].setText(self.down_items[i][1][1])
                byte_now = int(self.down_items[i][6][1])
                byte = int(self.down_items[i][4][1])
                tmp_sum = int(float(byte_now) / float(byte) * 100)
                self.dl_progressbar[i].setValue(tmp_sum)
                png = LOGODIR + '/%s.png'%self.down_items[i][1][1]
                self.dl_logo[i].setIcon(QIcon(png))
                self.dl_logo[i].setIconSize(QSize(64,64))
                if self.down_items[i][0][1] == 'stop':
                    self.dl_button_stat[i].setText(u'继续')
                if self.down_items[i][0][1] == 'ing':
                    self.dl_button_stat[i].setText(u'暂停')
                if self.down_items[i][0][1] == 'ok':
                    self.dl_button_stat[i].setText(u'安装')
                    self.dl_progressbar[i].setValue(100)
                n = n + 1
        nn = 10 - m
        hight = nn * 64 + 32
        self.setFixedHeight(hight)
        self.frame.setGeometry(0,0,457,hight)
        self.window2_button_close.setGeometry(179,hight - 32,99,32)
class WINDOW1(QDialog,ui_gamux_box.Ui_Dialog):
    def eventFilter(self, obj, event):
        s = obj.styleSheet()
        s = s.replace(' ','')
        num = len(s.split('(255,0,0)'))
        if event.type() == event.Enter:
            if num == 1:
                obj.setStyleSheet('font: 75 14pt "Loma";color: rgb(255, 0, 1);')
        if event.type() == event.Leave:
            if num == 1:
                obj.setStyleSheet('font: 75 14pt "Loma";color: rgb(255, 255, 255);')
        return False
    def pic_change(self):
        if self.logo_timer_i == 0:
            png = GAMUXBOXDIR+ '/images/8001500.png'
            self.window1_button_big_pic.setIcon(QIcon(png))
            self.window1_button_big_pic.setIconSize(QSize(800,150))
            for i in [1,2,3,4]:
               self.window1_button_pic_list[i].setStyleSheet('')
            self.window1_button_pic_list[0].setStyleSheet('background-color: rgb(255, 85, 0);')
        if self.logo_timer_i == 1:
            png = GAMUXBOXDIR + '/images/8001501.png'
            self.window1_button_big_pic.setIcon(QIcon(png))
            self.window1_button_big_pic.setIconSize(QSize(800,150))
            for i in [0,2,3,4]:
               self.window1_button_pic_list[i].setStyleSheet('')
            self.window1_button_pic_list[1].setStyleSheet('background-color: rgb(255, 85, 0);')
        if self.logo_timer_i == 2:
            png = GAMUXBOXDIR + '/images/8001502.png'
            self.window1_button_big_pic.setIcon(QIcon(png))
            self.window1_button_big_pic.setIconSize(QSize(800,150))
            for i in [0,1,3,4]:
               self.window1_button_pic_list[i].setStyleSheet('')
            self.window1_button_pic_list[2].setStyleSheet('background-color: rgb(255, 85, 0);')
        if self.logo_timer_i == 3:
            png = GAMUXBOXDIR + '/images/8001503.png'
            self.window1_button_big_pic.setIcon(QIcon(png))
            self.window1_button_big_pic.setIconSize(QSize(800,150))
            for i in [0,1,2,4]:
               self.window1_button_pic_list[i].setStyleSheet('')
            self.window1_button_pic_list[3].setStyleSheet('background-color: rgb(255, 85, 0);')
        if self.logo_timer_i == 4:
            png = GAMUXBOXDIR + '/images/8001504.png'
            self.window1_button_big_pic.setIcon(QIcon(png))
            self.window1_button_big_pic.setIconSize(QSize(800,150))
            for i in [0,1,2,3]:
               self.window1_button_pic_list[i].setStyleSheet('')
            self.window1_button_pic_list[4].setStyleSheet('background-color: rgb(255, 85, 0);')
        self.logo_timer_i = self.logo_timer_i + 1
        if self.logo_timer_i == 5:
            self.logo_timer_i = 0
    def __init__(self,parent=None):
        super(WINDOW1,self).__init__(parent)
        self.ini = ConfigParser.ConfigParser()
        self.ini.read(GAMELIST)
        self.sec_list = self.ini.sections()
        self.items = []
        self.game_sum_0 = len(self.sec_list) - 1
        for i in range(1,self.game_sum_0 + 1):
            self.items.append(self.ini.items('%s'%self.sec_list[i]))

        self.downloadlist = DOWNLIST
        self.down_ini = ConfigParser.ConfigParser()
        self.down_ini.read(self.downloadlist)
        self.down_sec_list = self.down_ini.sections()
        self.down_items = []
        for i in range(0,10):
            self.down_items.append(self.down_ini.items('%s'%self.down_sec_list[i]))

        self.setupUi(self)
        self.testTimer=QTimer(self)
        self.connect(self.testTimer,SIGNAL("timeout()"),self.pic_change)
        self.window1_button_pic_list = [self.window1_button_pic_0,self.window1_button_pic_1,self.window1_button_pic_2,self.window1_button_pic_3,self.window1_button_pic_4]
        self.window1_frame_list = [self.window1_frame_0,self.window1_frame_1,self.window1_frame_2,self.window1_frame_3,self.window1_frame_4]
        self.window1_button_logo_list = [self.window1_button_logo_0,self.window1_button_logo_1,self.window1_button_logo_2,self.window1_button_logo_3,self.window1_button_logo_4]
        self.window1_label_des_list = [self.window1_label_des_0,self.window1_label_des_1,self.window1_label_des_2,self.window1_label_des_3,self.window1_label_des_4]
        self.window1_label_name_list=[self.window1_label_name_0,self.window1_label_name_1,self.window1_label_name_2,self.window1_label_name_3,self.window1_label_name_4]
        self.window1_label_ver_list=[self.window1_label_ver_0,self.window1_label_ver_1,self.window1_label_ver_2,self.window1_label_ver_3,self.window1_label_ver_4]
        self.window1_button_menu_list=[self.window1_button_first,self.window1_button_man,self.window1_button_download_man,self.window1_button_installer,self.window1_button_getlib]
        self.window1_button_clicked_yes_no_list=['no','no','no','no','no']
        self.logo_timer_i = 0
        self.testTimer.start(3000)
        self.window1_label_games_num.setText(u'目前收录游戏:%s个'%self.game_sum_0)
        (page_sum_now,mod) = self.get_the_page_and_mod(self.game_sum_0)
        self.window1_label_page.setText(u'第1页 总%s页'%page_sum_now)
        self.page_now = 1
        self.items_now = self.items
        self.game_sum_now = self.game_sum_0
        self.show_list(self.items_now,self.game_sum_now)
        self.window1_button_first.setMouseTracking(True)
        for i in self.window1_button_menu_list:
            i.installEventFilter(self)
        self.window2class = WINDOW2(0,self)
    def send_emit(self,i,file_path):
        self.emit(SIGNAL("timeout()"), i,file_path)
    def setup_start(self,m):
        self.downloadlist = DOWNLIST
        self.down_ini = ConfigParser.ConfigParser()
        self.down_ini.read(self.downloadlist)
        self.down_sec_list = self.down_ini.sections()
        self.down_items = []
        for i in range(0,10):
            self.down_items.append(self.down_ini.items('%s'%self.down_sec_list[i]))
        pos = (self.page_now - 1) * 5 + m
        basename = os.path.basename(self.items[pos][5][1])
        file_path = GAMUX_DOWNLOAD_DIR + '/' + basename
        safe = 'no'
        for i in range(0,10):
            if self.down_items[i][0][1] != 'kill' and self.down_items[i][2][1] == self.items[pos][5][1]:
                safe = 'yes'
                dl = QMessageBox()
                dl.information(self,u'提示 ', u'已存在相同任务!',QMessageBox.Ok)
        if safe != 'yes':
            i = 0
            while i < 10:
                if self.down_items[i][0][1] == 'kill':
                    self.down_ini.set(self.down_sec_list[i],'stat','ing')
                    self.down_ini.set(self.down_sec_list[i],'name',self.items[pos][0][1])
                    self.down_ini.set(self.down_sec_list[i],'addr',self.items[pos][5][1])
                    self.down_ini.set(self.down_sec_list[i],'ver',self.items[pos][3][1])
                    self.down_ini.set(self.down_sec_list[i],'byte',self.items[pos][4][1])
                    self.down_ini.set(self.down_sec_list[i],'pic',self.items[pos][6][1])
                    self.down_ini.set(self.down_sec_list[i],'now_byte','0')
                    self.down_ini.set(self.down_sec_list[i],'file_path',file_path)
                    self.down_ini.write(open(self.downloadlist,"w"))
                    break
                i = i + 1
            if i == 10:
                dl = QMessageBox()
                dl.information(self,u'提示 ', u'提示:最多同时进行10个任务，下载槽已满，请打开下载管理器清除不需要的任!',QMessageBox.Ok)
            else:
                cmd = ['wget','-c','-O',file_path,self.items[pos][5][1]]
                PP_START[i] = subprocess.Popen(cmd)
                BEGINTIMER[i]=QTimer(self)
                BEGINTIMER[i].setProperty('obj',self.window2class)
                BEGINTIMER[i].setProperty('i',i)
                BEGINTIMER[i].setProperty('file_path',file_path)
                self.connect(BEGINTIMER[i],SIGNAL("timeout()"),self.flush )
                BEGINTIMER[i].start(500)
                self.window2class.show_download_window()
    def flush(self):
        i = self.sender().property('i').toInt()[0]
        file_path =  self.sender().property('file_path').toString()
        window2 = self.sender().property('obj').toPyObject()
        file_size = os.path.getsize(file_path)
        self.down_ini.set(self.down_sec_list[i],'now_byte',str(file_size))
        self.down_ini.write(open(self.downloadlist,"w"))
        byte = self.down_items[i][4][1]
        tmp_sum = int(float(file_size) / float(byte) *100)
        window2.dl_progressbar[i].setValue(tmp_sum)
        png = LOGODIR + '/%s.png'%self.down_items[i][1][1]
        window2.dl_logo[i].setIcon(QIcon(png))
        window2.dl_logo[i].setIconSize(QSize(64,64))
        if PP_START[i].poll() == 0:
            self.down_ini.set(self.down_sec_list[i],'stat','ok')
            self.down_ini.write(open(self.downloadlist,"w"))
            window2.dl_progressbar[i].setValue(100)
            window2.dl_button_stat[i].setText(u'安装')
            window2.dl_progressbar[i].setValue(100)
            BEGINTIMER[i].stop()
    @pyqtSignature("")
    def on_window1_button_az_1_clicked(self):
        self.setup_start(0)
        self.window2class.show()
    def on_window1_button_az_2_clicked(self):
        self.setup_start(1)
        self.window2class.show()
    def on_window1_button_az_3_clicked(self):
        self.setup_start(2)
        self.window2class.show()
    def on_window1_button_az_4_clicked(self):
        self.setup_start(3)
        self.window2class.show()
    def on_window1_button_az_5_clicked(self):
        self.setup_start(4)
        self.window2class.show()
    @pyqtSignature("")
    def on_window1_button_first_clicked(self):
        self.window1_button_clicked_yes_no_list[0] = 'yes'
        for i in [1,2,3,4]:
            self.window1_button_menu_list[i].setStyleSheet('font: 75 14pt "Loma";color: rgb(255, 255, 255);')
        self.window1_button_menu_list[0].setStyleSheet('font: 75 16pt "Loma";color: rgb(255, 0, 0);')
    @pyqtSignature("")
    def on_window1_button_man_clicked(self):
        self.window1_button_clicked_yes_no_list[1] = 'yes'
        for i in [0,2,3,4]:
            self.window1_button_menu_list[i].setStyleSheet('font: 75 14pt "Loma";color: rgb(255, 255, 255);')
        self.window1_button_menu_list[1].setStyleSheet('font: 75 16pt "Loma";color: rgb(255, 0, 0);')
    @pyqtSignature("")
    def on_window1_button_download_man_clicked(self):
        self.window1_button_clicked_yes_no_list[2] = 'yes'
        for i in [0,1,3,4]:
            self.window1_button_menu_list[i].setStyleSheet('font: 75 14pt "Loma";color: rgb(255, 255, 255);')
        self.window1_button_menu_list[2].setStyleSheet('font: 75 16pt "Loma";color: rgb(255, 0, 0);')
        self.window2class.show()
    @pyqtSignature("")
    def on_window1_button_installer_clicked(self):
        self.window1_button_clicked_yes_no_list[3] = 'yes'
        for i in [0,1,2,4]:
            self.window1_button_menu_list[i].setStyleSheet('font: 75 14pt "Loma";color: rgb(255, 255, 255);')
        self.window1_button_menu_list[3].setStyleSheet('font: 75 16pt "Loma";color: rgb(255, 0, 0);')
    @pyqtSignature("")
    def on_window1_button_getlib_clicked(self):
        self.window1_button_clicked_yes_no_list[4] = 'yes'
        for i in [0,1,2,3]:
            self.window1_button_menu_list[i].setStyleSheet('font: 75 14pt "Loma";color: rgb(255, 255, 255);')
        self.window1_button_menu_list[4].setStyleSheet('font: 75 16pt "Loma";color: rgb(255, 0, 0);')
    @pyqtSignature("")
    def on_window1_button_down_clicked(self):
        items_now = self.items_now
        game_sum_now = self.game_sum_now
        (page_sum_now,mod) = self.get_the_page_and_mod(game_sum_now)
        if self.page_now == page_sum_now:
            dl = QMessageBox()
            dl.information(self,u'提示 ',u'提示:已经是尾页!',QMessageBox.Ok)
        elif self.page_now == page_sum_now - 1:
            if game_sum_now > 5 and mod != 0:
                for i in range(mod,5):
                    self.window1_frame_list[i].hide()
                for i in range(0,mod):
                    self.window1_label_name_list[i].setText(unicode(items_now[i + (page_sum_now - 1) * 5][0][1]))
                    self.window1_label_ver_list[i].setText(unicode(items_now[i + (page_sum_now - 1) * 5][3][1]))
                    self.window1_label_des_list[i].setText(unicode(items_now[i + (page_sum_now - 1) * 5][7][1]))
                    self.set_logo(items_now[i + (page_sum_now - 1) * 5][0][1],i)
                self.page_now = self.page_now + 1
                self.window1_label_page.setText(u'第%s页  总%s页'%(self.page_now,page_sum_now))
        else:
            self.show_list(self.items,game_sum_now,self.page_now + 1)
            self.page_now = self.page_now + 1
            self.window1_label_page.setText(u'第%s页  总%s页'%(self.page_now,page_sum_now))
    @pyqtSignature("")
    def on_window1_button_up_clicked(self):
        items_now = self.items_now
        game_sum_now = self.game_sum_now
        (page_sum_now,mod) = self.get_the_page_and_mod(game_sum_now)
        if self.page_now == page_sum_now and mod != 0 and page_sum_now != 1:
            for i in range(0,5):
                self.window1_frame_list[i].show()
        if self.page_now == 1:
            dl = QMessageBox()
            dl.information(self,u'提示 ',u'提示:已经是首页!',QMessageBox.Ok)
        else:
            self.page_now = self.page_now - 1
            self.show_list(items_now,game_sum_now)
            self.window1_label_page.setText(u'第%s页  总%s页'%(self.page_now,page_sum_now))
    def get_logo(self,name,i,logo_path):
        server_logo_addr = 'http://game-logo.qiniudn.com/%s.png'%name
        cmd = ['wget','-O',logo_path,server_logo_addr]
        pp = subprocess.Popen(cmd)
        if os.path.exists(logo_path) and os.path.getsize(logo_path) != 0 :
            self.testTimer_get_logo_list[i].stop()
            self.window1_button_logo_list[i].setIcon(QIcon(logo_path))
            self.window1_button_logo_list[i].setIconSize(QSize(64,64))
        else:
            default = GAMUXBOXDIR + '/images/logo64.png'
            self.window1_button_logo_list[i].setIcon(QIcon(default))
            self.window1_button_logo_list[i].setIconSize(QSize(64,64))
    def set_logo(self,name,i):
        logo_path = LOGODIR + '/%s.png'%name
        if os.path.exists(logo_path) and os.path.getsize(logo_path) != 0 :
            self.window1_button_logo_list[i].setIcon(QIcon(logo_path))
            self.window1_button_logo_list[i].setIconSize(QSize(64,64))
        else:
            self.get_logo(name,i,logo_path)
    def get_the_page_and_mod(self,game_sum_now):
        mod = game_sum_now % 5
        if game_sum_now < 6:
            page_num = 1
            return(page_num,mod)
        elif mod != 0:
            page_num = int(float(game_sum_now)/5.0) + 1
            return(page_num,mod)
        else:
            page_num = int(float(game_sum_now)/5.0)
            return(page_num,mod)
    def show_list(self,items_now,game_sum_now):
        (page_sum_now,mod) = self.get_the_page_and_mod(game_sum_now)
        if game_sum_now < 5:
            for i in range(game_sum_now,5):
                self.window1_frame_list[i].hide()
        if game_sum_now < 5:
            for i in range(0,game_sum_now):
                self.window1_label_name_list[i].setText(unicode(items_now[i][0][1]))
                self.window1_label_ver[i].set_text(unicode(items_now[i][3][1]))
                self.window1_label_des_list[i].setText(unicode(items_now[i][7][1]))
                self.set_logo(items_now[i][0][1],i)
        else:
            for i in range(0,5):
                self.window1_label_name_list[i].setText(unicode(items_now[i + (self.page_now - 1) * 5][0][1]))
                self.window1_label_ver_list[i].setText(unicode(items_now[i + (self.page_now- 1) * 5][3][1]))
                self.window1_label_des_list[i].setText(unicode(items_now[i + (self.page_now - 1) * 5][7][1]))
                self.set_logo(items_now[i + (self.page_now - 1) * 5][0][1],i)
    @pyqtSignature("")
    def on_window1_button_pic_0_clicked(self):
        self.logo_timer_i = 0
        self.pic_change()
    @pyqtSignature("")
    def on_window1_button_pic_1_clicked(self):
        self.logo_timer_i = 1
        self.pic_change()
    @pyqtSignature("")
    def on_window1_button_pic_2_clicked(self):
        self.logo_timer_i = 2
        self.pic_change()
    @pyqtSignature("")
    def on_window1_button_pic_3_clicked(self):
        self.logo_timer_i = 3
        self.pic_change()
    @pyqtSignature("")
    def on_window1_button_pic_4_clicked(self):
        self.logo_timer_i = 4
        self.pic_change()
if __name__ == '__main__':
    reload(sys)
    sys.setdefaultencoding('utf-8')
    GAMUX_BOX_VER = 2014033020
    HOME = os.environ['HOME']
    GAMES = HOME + '/games'
    if os.path.exists(GAMES)==False:
        os.mkdir(GAMES)
    GAMUXBOXDIR = HOME + '/.gamuxbox'
    if os.path.exists(GAMUXBOXDIR)==False:
        os.mkdir(GAMUXBOXDIR)
    GAMELIST = GAMUXBOXDIR + '/gamelist'
    DOWNLIST = GAMUXBOXDIR + '/downloadlist'
    LOGODIR = GAMUXBOXDIR + '/logo'
    if os.path.exists(LOGODIR)==False:
        os.mkdir(LOGODIR)
    GAMUXDIR = HOME + '/.gamux'
    if os.path.exists(GAMUXDIR)==False:
        os.mkdir(GAMUXDIR)
    TMP_PATH = HOME + '/.tmp'
    if os.path.exists(TMP_PATH)==False:
        os.mkdir(TMP_PATH)
    GAMUX_DOWNLOAD_DIR = HOME + '/gamux_download'
    if os.path.exists(GAMUX_DOWNLOAD_DIR)==False:
        os.mkdir(GAMUX_DOWNLOAD_DIR)
    PP_START= ['','','','','','','','','','']
    BEGINTIMER=['','','','','','','','','','']
    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon('./images/logo.png'))
    box = WINDOW1()
    box.show()
    app.exec_()
